/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package evaluateur;

import java.util.ArrayList;
import requeteur.Paragraphe;

/**
 *
 * @author Cyril
 */
public class Evaluator {
    
    private ArrayList<Integer> qrelResults;
    
    public Evaluator(ArrayList<Integer> qrelResults) {
        this.qrelResults = qrelResults;
    }
    
    public float getRappel(ArrayList<Paragraphe> res) {
        int cpt=0;
        ArrayList<Integer> idList = new ArrayList<Integer>();
        for(Paragraphe p : res) {
            idList.add(p.getIdParagraphe());
        }
        for(Integer id : qrelResults) {
            if (idList.contains(id)) {
                cpt++;
            }
        }
        System.out.println(cpt);
        return cpt/idList.size();
    }
    
    public float getPrecision(ArrayList<Paragraphe> res) {
        int cpt=0;
        for(Paragraphe p : res) {
            if (qrelResults.contains(p.getIdParagraphe())) {
                cpt++;
            }
        }
        System.out.println(cpt);
        return cpt/res.size();
    }
}
